﻿<UserControl x:Class="Samples.GasyTek.Lakana.Navigation.Features.ProductListView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d"
             d:DesignHeight="300"
             d:DesignWidth="300"
             x:Name="RootView"
             Style="{StaticResource ViewDefaultStyle}">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <Image Source="../Resources/info.png"
               Width="16"
               Height="16"
               Margin="20,0,0,0"
               HorizontalAlignment="Center"
               VerticalAlignment="Center" />

        <FlowDocumentScrollViewer Grid.Column="1"
                                  Margin="0,0,0,5">
            <FlowDocument>
                <Paragraph>
                    <Run Text="{Binding Description, Mode=OneTime}"
                         FontFamily="Segoe"
                         FontSize="12"
                         Foreground="White" />
                </Paragraph>
            </FlowDocument>
        </FlowDocumentScrollViewer>

        <ListBox Grid.Row="1"
                 Grid.ColumnSpan="2"
                 ItemsSource="{Binding Products}"
                 Margin="5"
                 BorderThickness="0">
            <ListBox.Resources>
                <Style TargetType="ListBoxItem">
                    <Setter Property="HorizontalContentAlignment"
                            Value="Stretch" />
                    <Setter Property="Margin"
                            Value="5,2.5,5,5" />
                </Style>
            </ListBox.Resources>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Border BorderBrush="White"
                            BorderThickness="1"
                            CornerRadius="2"
                            Padding="4">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="{Binding Name, StringFormat=Name : {0}}" />
                            <TextBlock Grid.Row="1"
                                       Margin="0,2,0,0"
                                       Text="{Binding Quantity, StringFormat=Quantity : {0}}" />

                            <Button Grid.RowSpan="2"
                                    Grid.Column="1"
                                    Content="Edit"
                                    Command="{Binding ElementName=RootView, Path=DataContext.EditProductCommand}"
                                    CommandParameter="{Binding}"
                                    HorizontalAlignment="Left"
                                    VerticalAlignment="Center"
                                    Width="80" />
                        </Grid>
                    </Border>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</UserControl>
